home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-10-26 | 3.3 KB | 63 lines | [TEXT/$Tcl] |
-
-
- TCL LOADABLE LIBRARIES AND PACKAGES
- Extended Tcl supports standard Tcl tclIndex libraries and
- package libraries. A package library file can contain multi-
- ple independent Tcl packages. A package is a named collec-
- tion of related Tcl procedures and initialization code.
-
- The package library file is just a regular Unix text file,
- editable with your favorite text editor, containing packages
- of Tcl source code. The package library file name must have
- the suffix .tlib. An index file with the suffix .tndx,
- corresponding to the package library. The .tndx will be
- automatically created by Tcl whenever it is out of date or
- missing (provided there is write access to the directory.
-
- The variable auto_path contains a list of directories that
- are searched for libraries. The first time an unknown com-
- mand trap is take, the indexes for the libraries are loaded
- into memory. If the auto_path variable is changed during
- execution of a program, it will be re-searched. Only the
- first package of a given name found during the execution of
- a program is loaded. This can be overridden with loadlibin-
- dex command.
-
- The start of a package is delimited by:
-
- #@package: package_name proc1 ?..procN?
-
- These lines must start in column one. Everything between
- the #@package: keyword and the next #@package: keyword or a
- #@packend keyword, or the end of the file, becomes part of
- the named package. The specified procedures, proc1..procN,
- are the entry points of the package. When a command named
- in a package specification is executed and detected as an
- unknown command, all code in the specified package will be
- sourced. This package should define all of the procedures
- named on the package line, define any support procedures
- required by the package and do any package-specific initial-
- ization. Packages declarations maybe continued on subse-
- quent lines using standard Tcl backslash line continuations.
- The #@packend keyword is useful to make sure only the
- minimum required section of code is sourced. Thus for exam-
- ple a large comment block at the beginning of the next file
- won't be loaded.
-
- Care should be taken in defining package_name, as the first
- package found in the path by with a given name is loaded.
- This can be useful in developing new version of packages
- installed on the system.
-
- For example, in a package source file, the presence of the
- following line:
-
- #@package: directory_stack pushd popd dirs
-
- says that the text lines following that line in the package
- file up to the next package line or the end of the file is a
- package named directory_stack and that an attempt to execute
- either pushd, popd or dirs when the routine is not already
- defined will cause the directory_stack portion of the pack-
- age file to be loaded.
-